﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.processor.type.comm;
using SharpSqlAnalyzer.pp.stmtformatter;
using SharpSqlAnalyzer.pp.utils;
using SharpSqlAnalyzer.stmt;

namespace SharpSqlAnalyzer.pp.processor.type.createview
{
	// Token: 0x02000245 RID: 581
	public class CreateViewReturnProcessor : AbstractProcessor
	{
		// Token: 0x06001301 RID: 4865 RVA: 0x0031C0B4 File Offset: 0x0031A2B4
		public override void process(TParseTreeNode nodeArg)
		{
			TCreateViewSqlStatement tcreateViewSqlStatement = nodeArg as TCreateViewSqlStatement;
			TSourceToken startToken = tcreateViewSqlStatement.startToken;
			if (startToken == null)
			{
				return;
			}
			int num = SourceTokenOperator.curColumnNumberVT(startToken);
			TSelectSqlStatement subquery = tcreateViewSqlStatement.Subquery;
			if (subquery == null)
			{
				return;
			}
			TSourceToken tsourceToken = SourceTokenSearcher.backforwardSearch(subquery.startToken, 5, "as");
			if (tsourceToken == null)
			{
				return;
			}
			SourceTokenOperator.addBefore(this.Option, tsourceToken, SourceTokenOperator.createReturnSourceToken());
			SourceTokenOperator.addBefore(this.Option, tsourceToken, SourceTokenOperator.createWhitespaceSourceToken(num));
			TSourceToken startToken2 = subquery.startToken;
			if (startToken2 == null)
			{
				return;
			}
			SourceTokenOperator.addBefore(this.Option, startToken2, SourceTokenOperator.createReturnSourceToken());
			SourceTokenOperator.addBefore(this.Option, startToken2, SourceTokenOperator.createWhitespaceSourceToken(num + this.Option.beStyleBlockIndentSize));
			FormatterFactory.processStatement(this.Option, subquery);
		}
	}
}
